package com.rxt.controller;


import com.rxt.common.result.Result;
import com.rxt.model.domain.FBank;
import com.rxt.model.domain.UExpert;
import com.rxt.model.vo.BankPageVo;
import com.rxt.model.vo.BankUserLoginVo;
import com.rxt.model.vo.BankVo;
import com.rxt.model.vo.UExpertPageVo;
import com.rxt.service.IFBankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 周梓文
 * @since 2023-08-24
 */
@Api(tags = "银行模块")
@RestController
@RequestMapping("/fBank")
public class FBankController {

    @Autowired
    private IFBankService ifBankService;

    /*
    添加银行
     */
    @ApiOperation("添加银行")
    @PostMapping("/save")
    public Result save(@RequestBody BankVo bankVo) {
        return ifBankService.insert(bankVo);
    }

    /*
    修改银行信息
     */
    @PutMapping
    @ApiOperation("修改银行信息")
    public Result update(BankVo bankVo){

        return ifBankService.updateBankById(bankVo);
    }

    /*
    根据id查找银行信息
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询单个银行信息")
    public Result getOne(@PathVariable Long id){

        return ifBankService.getOneByID(id);
    }

    /*
    分页查找银行
     */
    @GetMapping
    //加上此注解代表要对此接口记录日志
    @ApiOperation("分页获取银行列表")
    public Result page(BankPageVo page){
        return ifBankService.getPage(page);
    }

    @ApiOperation("获取所有银行信息")
    @GetMapping("/list")
    public Result list() {
        List<FBank> fBanks = ifBankService.list();
        return Result.ok(fBanks);
    }

    /*
    根据id删除银行
     */
    @DeleteMapping("/{id}")
    @ApiOperation("删除银行")
    public Result delete(@PathVariable Long id){

        return ifBankService.dedleteById(id);
    }


}

